package com.changsideal.util;

import lombok.extern.slf4j.Slf4j;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @ClassName PropertyUtil
 * @Description TODO
 * @Author Create by Chansideal.Haosc
 * @Date 2019/1/22 15:00
 * @Version 1.0
 **/
@Slf4j
public final class PropertyUtil {

    public static Properties getProperty(String configName) {
        Properties properties = new Properties();
        try(InputStream inputStream = PropertyUtil.class.getClassLoader().getResourceAsStream(configName)) {
            properties.load(inputStream);
        } catch (IOException e) {
            log.error("获取配置configName :{}信息异常！" , configName);
            e.printStackTrace();
        }
        return properties;
    }

    public static String getConfigString(Properties properties, String strKey) {
        return properties.getProperty(strKey);
    }

    public static void main(String[] args) {
        Properties properties = getProperty("aws.properties");
        System.out.println(getConfigString(properties, "versioned_bucket"));
    }
}
